package com.xuecheng.content.api;

import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 师资管理类接口
 */
@Api(value = "师资管理类接口",tags = "师资管理类接口")
@Slf4j
@RestController
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService courseTeacherService;

    @ApiOperation("师资查询接口")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> getCourseTeacher(@PathVariable("courseId") Long courseId){

        return courseTeacherService.getCourseTeacher(courseId);
    }

    @ApiOperation("师资添加/修改接口")
    @PostMapping("/courseTeacher")
    public CourseTeacher insertCourseTeacher(@RequestBody @Validated CourseTeacher courseTeacher){

        Long companyId = 22L;
        return courseTeacherService.insertCourseTeacher(courseTeacher,companyId);
    }

    @ApiOperation("师资删除接口")
    @DeleteMapping("/courseTeacher/course/{courseId}/{id}")
    public void delCourseTeacher(@PathVariable("courseId") Long courseId,@PathVariable("id")Long id){

        Long companyId = 22L;
        courseTeacherService.delCourseTeacher(courseId,id,companyId);
    }
}
